package com.ynny.Service.Impl;

import com.ynny.Dao.UserManagerDao;
import com.ynny.Entity.Users;
import com.ynny.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImp implements UserService {
    @Autowired
    private UserManagerDao userManagerDao;
    @Override
    public int login(String number, String password) {
        //检查用户是否存在
        Users users = userManagerDao.queryUserByNumber(number);
        if(users == null){
            System.out.println("用户不存在！");
            return -1;//用户不存在
        }else if(!users.getPassword().equals(password)){
            System.out.println("密码错误！");
            return -2;//密码错误
        }else{
            System.out.println(users.getIdentity()+"用户登录成功！");
            return 1;//登录成功
        }
    }

    @Override
    public void quit() {
        System.out.println("用户退出！");
        System.exit(0);
    }
}
